/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.sentry.protocol;

import io.sentry.IUnknownPropertiesConsumer;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
 * Debugging and processing meta information.
 *
 * <p>The debug meta interface carries debug information for processing errors and crash reports.
 * Sentry amends the information in this interface.
 *
 * <p>Example (look at field types to see more detail):
 *
 * <p>```json { "debug_meta": { "images": [], "sdk_info": { "sdk_name": "iOS", "version_major": 10,
 * "version_minor": 3, "version_patchlevel": 0 } } } ```
 *
 * @since 2021-06-02
 */
public final class DebugMeta implements IUnknownPropertiesConsumer {
    /**
     * Information about the system SDK (e.g. iOS SDK).
     */
    private @Nullable SdkInfo sdkInfo;
    /**
     * List of debug information files (debug images).
     */
    private @Nullable List<DebugImage> images;

    @SuppressWarnings("unused")
    private @Nullable Map<String, Object> unknown;

    public @Nullable List<DebugImage> getImages() {
        return images;
    }

    public void setImages(final @Nullable List<DebugImage> images) {
        this.images = images != null ? new ArrayList<>(images) : null;
    }

    public @Nullable SdkInfo getSdkInfo() {
        return sdkInfo;
    }

    public void setSdkInfo(final @Nullable SdkInfo sdkInfo) {
        this.sdkInfo = sdkInfo;
    }

    @ApiStatus.Internal
    @Override
    public void acceptUnknownProperties(final @NotNull Map<String, Object> unknowns) {
        this.unknown = unknowns;
    }
}
